package com.ai.bitcoin.weixin.template;

import com.ai.bitcoin.constant.CommonConstant;
import com.ai.bitcoin.constant.WeiXinConfig;
import com.ai.bitcoin.util.DateUtil;
import com.google.common.collect.Maps;

import java.util.Date;
import java.util.Map;

/**
 * 币订阅推送模板
 */
public class CoinReportTemplate extends BaseTemplate{

    private final String templateId = WeiXinConfig.COIN_REPORT_TEMPLATE_ID;

    /**
     *
     {{first.DATA}}
     认证姓名：{{keyword1.DATA}}
     认证套餐：{{keyword2.DATA}}
     认证状态：{{keyword3.DATA}}
     生成时间：{{keyword4.DATA}}
     {{remark.DATA}}
     * @param request
     * @return
     */
    @Override
    public Map<String, Object> buildParameterMap(Map<String, Object> request) {
        Map<String,Object> resp = Maps.newHashMap();
        resp.put("touser", request.get("openId"));
        resp.put("template_id", templateId);
        resp.put("url", request.get("url"));
        Map<String,Object> dataMap = Maps.newHashMap();
        dataMap.put("first", buildDataMap(String.valueOf(request.get("first"))));
        dataMap.put("keyword1", buildDataMap(String.valueOf(request.get("keyword1"))));
        dataMap.put("keyword2", buildDataMap(String.valueOf(request.get("keyword2"))));
        dataMap.put("keyword3", buildDataMap("订阅中"));
        dataMap.put("keyword4", buildDataMap(DateUtil.toDateStr(new Date(), CommonConstant.DAY_TIME_PATTERN)));
        if(request.get("remark") != null) {
            dataMap.put("remark", buildDataMap(String.valueOf(request.get("remark"))));
        }
        resp.put("data", dataMap);
        return resp;
    }

}
